package com.talkweb.demo.search;

import cn.hutool.core.util.StrUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Scanner;

/**
 * @description: 描述
 * @className：Test
 * @author: lj
 * @date: 2024/10/8 17:47
 */
public class App {
    private final static Logger log = LoggerFactory.getLogger(App.class);
    private static final String PDF = "1";
    private static final String TXT_MODIFY = "2";
    private static final String TXT = "3";

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String type = null;
        while (null == type) {
            System.out.println("[1] 直接扫描pdf文件内容");
            System.out.println("[2] 规范ORC识别出的txt内容");
            System.out.println("[3] 根据OCR识别出的txt内容扫描pdf文件");
            System.out.print("请输入操作编号[1]：");
            String input = scanner.nextLine();
            if (StrUtil.isNotBlank(input)) {
                input = input.trim();
                if (PDF.equalsIgnoreCase(input) || TXT_MODIFY.equalsIgnoreCase(input) || TXT.equalsIgnoreCase(input)) {
                    type = input;
                    break;
                }
            }else{
                type = PDF;
                break;
            }
        }

        if (PDF.equalsIgnoreCase(type)) {
            FileCacheUtil.init("cache.txt");
            PdfSearch.search(scanner);
        }if (TXT_MODIFY.equalsIgnoreCase(type)) {
            FileCacheUtil.init("cache-txt-modify.txt");
            TxtModify.search(scanner);
        } else {
            FileCacheUtil.init("cache-txt.txt");
            TxtSearch.search(scanner);
        }
    }
}
